package com.keba.lamp.complaint.enumeration;

import com.keba.basic.interfaces.BaseEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.stream.Stream;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 增量文件上传日志
 * </p>
 *
 * @author chaowu.wang
 * @date 2025-03-14 22:47:07
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "存储类型-枚举")
public enum FileStorageType implements BaseEnum {

    /**
     * LOCAL
     */
    LOCAL("本地"),
    /**
     * FAST_DFS
     */
    FAST_DFS("FastDFS"),
    /**
     * MIN_IO
     */
    MIN_IO("MinIO"),
    /**
     * ALI_OSS
     */
    ALI_OSS("阿里云OSS"),
    /**
     * QINIU_OSS
     */
    QINIU_OSS("七牛云OSS"),
    /**
     * HUAWEI_OSS
     */
    HUAWEI_OSS("华为云OSS"),
    ;

    @Schema(description = "描述")
    private String desc;

    /**
     * 根据当前枚举的name匹配
     */
    public static FileStorageType match(String val, FileStorageType def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static FileStorageType get(String val) {
        return match(val, null);
    }

    public boolean eq(FileStorageType val) {
        return val != null && eq(val.name());
    }

    @Override
    @Schema(description = "name", allowableValues = "LOCAL,FAST_DFS,MIN_IO,ALI_OSS,QINIU_OSS,HUAWEI_OSS", example = "LOCAL")
    public String getCode() {
        return this.name();
    }

    @Override
    @Schema(description = "数据库中的值")
    public String getValue() {
        return this.name();
    }

}
